import subprocess
import sys
import time

# 启动天气数据API（5000端口）
api_process = subprocess.Popen([sys.executable, "api.py"])
# 等待2秒确保API已启动
time.sleep(2)
# 启动DeepSeek服务（5001端口）
deepseek_process = subprocess.Popen([sys.executable, "../weather_integration/deepseek_weather.py"])

try:
    # 保持主进程运行，直到子进程退出
    api_process.wait()
    deepseek_process.wait()
except KeyboardInterrupt:
    # 按Ctrl+C时终止子进程
    api_process.terminate()
    deepseek_process.terminate()
    print("服务已停止")